package test.other.Quest;

import java.util.Arrays;

/**
 * @author 星环
 * @date 2023/1/11 15:40:28
 * @description
 */
public class EE {
    public static void main(String[] args) {
        Solution solution = new Solution(new int[]{1, 2, 3});
        System.out.println(Arrays.toString(solution.shuffle()));
    }
}

class Solution {

    private int[] nums;
    public Solution(int[] nums) {
        //等可能随机
        //存储原始状态
        this.nums = nums;
    }

    public int[] reset() {
        return nums;
    }

    public int[] shuffle() {
        int [] ret = new int[nums.length];
        for(int i = 0;i < ret.length;i++){
            ret[i] = 1000_0000_1;
        }
        //打乱数组
        for(int i = 0;i < nums.length;i++){
            int index = 0;
            do{
                index = (int)(Math.random() * nums.length);
            }while(ret[index] != 1000_0000_1);
            ret[index] = nums[i];
        }
        return ret;
    }
}

/**
 * Your Solution object will be instantiated and called as such:
 * Solution obj = new Solution(nums);
 * int[] param_1 = obj.reset();
 * int[] param_2 = obj.shuffle();
 */